<?php
namespace app\finance\model;
use think\Db;
use app\common\model\Common;
class Refund extends Common
{
	protected $table = 'mps_refund_booking';
	protected $append = ['supplier_name','ty_text'];
	/**
	* 退款总额
	*/
	public function allMoney($where, $order, $search)
	{
		return $this->where($where)->where($search)->order($order)->sum('money');
	}
	/**
	* 获取器
	*/
	public function getAddtimeAttr($value){
		return $value > 0 ? date('Y-m-d H:i:s',$value) : '---';
	}
	public function getSupplierNameAttr($value, $data){
		return Db::name('supplier')->where('supplier_id',$data['supplier_id'])->value('supplier_name');
	}
	public function getTyTextAttr($value){
		switch($value){
			case 0: return '召回';break;
			case 1: return '退货';break;
			default: return '异常';break;
		}
	}
}